﻿<UserControl x:Class="Chapters.Chapter05.ScrollBarExample"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<UserControl.Resources>
		<LinearGradientBrush x:Key="ThumbBrush"
							 StartPoint="0,0"
							 EndPoint="1,0">
			<GradientStop Offset="0"
						  Color="#c1dbe8" />
			<GradientStop Offset="0.5"
						  Color="#008fc7" />
			<GradientStop Offset="1"
						  Color="#066caa" />
		</LinearGradientBrush>
		
		<LinearGradientBrush x:Key="TrackBrush"
							 StartPoint="0,0"
							 EndPoint="1,0">
			<GradientStop Offset="0"
						  Color="#bcbcbc" />
			<GradientStop Offset="0.75"
						  Color="#eeeeee" />
			<GradientStop Offset="1"
						  Color="#eeeeee" />
		</LinearGradientBrush>
		
		<ControlTemplate x:Key="RBTemplate"
						 TargetType="RepeatButton">
			<Rectangle Fill="Transparent" />
		</ControlTemplate>
		<ControlTemplate x:Key="ThumbTemplate"
						 TargetType="Thumb">
			<Border Background="{TemplateBinding BorderBrush}"
					CornerRadius="30,5,5,30"
					BorderThickness="0"
					Padding="1">
				<Border Background="{TemplateBinding Background}"
						CornerRadius="30,5,5,30"
						BorderThickness="0" />
			</Border>
		</ControlTemplate>
		
		<ControlTemplate x:Key="VerticalScrollBarTemplate"
						 TargetType="ScrollBar">
			<Grid>
				<Border CornerRadius="30,5,5,30"
						Background="{StaticResource TrackBrush}"
						BorderBrush="#999999"
						BorderThickness="1"
						Padding="1">
					<Track x:Name="PART_Track"
						   IsDirectionReversed="True">
						<Track.DecreaseRepeatButton>
							<RepeatButton Command="ScrollBar.PageUpCommand"
										  Template="{StaticResource RBTemplate}" />
						</Track.DecreaseRepeatButton>
						<Track.Thumb>
							<Thumb Template="{StaticResource ThumbTemplate}"
								   Background="{TemplateBinding Background}"
								   BorderThickness="1"
								   BorderBrush="{TemplateBinding BorderBrush}" />
						</Track.Thumb>
						<Track.IncreaseRepeatButton>
							<RepeatButton Command="ScrollBar.PageDownCommand"
										  Template="{StaticResource RBTemplate}" />
						</Track.IncreaseRepeatButton>
					</Track>
				</Border>
			</Grid>
		</ControlTemplate>

		<Style x:Key="{x:Type ScrollBar}"
			   TargetType="ScrollBar">
			<Setter Property="MinWidth"
					Value="22" />
			<Setter Property="Background"
					Value="{StaticResource ThumbBrush}" />
			<Setter Property="BorderBrush"
					Value="#999999" />
			<Setter Property="Template"
					Value="{StaticResource VerticalScrollBarTemplate}" />
		</Style>
		
	</UserControl.Resources>
	<Grid>
		<ScrollBar Orientation="Vertical"
				   Minimum="0"
				   Maximum="100"
				   ViewportSize="25"
				   Margin="20" />
	</Grid>
</UserControl>
